<?php
    include('include/function.php');
    valid_user();
    $user_id = $_SESSION['user_id'];
    if (get_magic_quotes_gpc())
        $_GET['contest_id'] = stripslashes($_GET['contest_id']);
    $contest_id = mysql_escape_string($_GET['contest_id']);
    valid_contest($contest_id);
    include('include/header.php');
    $contest_title = get_contest_title($contest_id);
?>
<title>Contest Status</title>
    <div id="headline">
        <div class="wrapper">
            <h2>Contest - <?php echo $contest_title; ?></h2>
        </div>
    </div>    
    
<div id="pagebody">
	<div class="wrapper">
    <table class="center" id="contest_list">
    <thead>
        <tr>
            <th width="100">Run ID</th>
            <th width="75">Problem</th>
            <th width="200">Result</th>
            <th width="85">Language</th>
            <th width="160">Submit Time</th>
        </tr>
    </thead>
<tbody>

<?php
    $runs = get_runs($contest_id, $user_id);
    if (!empty($runs)) {
        $rows = count($runs);

        for ($i = 0; $i < $rows; $i++){
            echo '<tr>';

            $run_id = $runs[$i]['run_id'];
            $problem = $runs[$i]['as_problem'];
            $problem_url = $runs[$i]['url'];
            $result = $runs[$i]['result'];
            $language = $runs[$i]['language'];
            $submit_time = $runs[$i]['submit_time'];

            echo "<td>$run_id</td>";
            echo "<td><a href=\"$problem_url\">$problem</a></td>";
            echo "<td style=\"color:{$STATUS_COLOR[$result]}\"><strong>$result</strong></td>";
            echo "<td><a href=\"code?run_id=$run_id&problem=$problem\">$language</a></td>";
            echo "<td>$submit_time</td>";
            echo "</tr>";
        }
    }
?>
    </tbody></table>
    </div>
</div>
<br/>
<?php
	include('include/footer.php');
?>
